package dbexp.utils;

public class Default {
	public Default() {

	}

	public String getPort() {
		String url = "";
		try {
			url = DbProperties.getInstance().getURL();// jdbc:oracle:thin:@oracle.pwsz.elblag.pl:1521:ORA9i
			url = url.substring(url.indexOf("@") + 1);// oracle.pwsz.elblag.pl:1521:ORA9i
			url = url.substring(url.indexOf(":") + 1, url.lastIndexOf(":"));// ORA9i
		} catch (IndexOutOfBoundsException e) {
		}
		if (url.trim().length() > 0) {
			return url.trim();// ORA9i
		} else {
			return DbProperties.getInstance().getPort();
		}
	}

	public String getHostName() {
		String url = "";
		try {
			url = DbProperties.getInstance().getURL();// jdbc:oracle:thin:@oracle.pwsz.elblag.pl:1521:ORA9i
			url = url.substring(url.indexOf("@") + 1);// oracle.pwsz.elblag.pl:1521:ORA9i
			url = url.substring(0, url.indexOf(":"));// jdbc:oracle:thin
		} catch (IndexOutOfBoundsException e) {
		}
		if (url.trim().length() > 0) {
			return url.trim();// oracle.pwsz.elblag.pl
		} else {
			return DbProperties.getInstance().getHostName();
		}
	}

	public String getDbName() {
		String url = DbProperties.getInstance().getURL();// jdbc:oracle:thin:@oracle.pwsz.elblag.pl:1521:ORA9i
		url = url.substring(url.lastIndexOf(":") + 1);// ORA9i
		if (url.trim().length() > 0) {
			return url.trim();// ORA9i
		} else {
			return "orcl";
		}
	}
}
